#include "./qihai_tcpserver/TcpServer.hpp"

using namespace qihai;

void func(TcpServer* server, ClientInfo* clientInfo)
{
    // 任务函数
    // 当前服务器任务，接收客户端发送的信息，并且返回
    bool isClose = false;
    while (true)
    {
        std::string message = server->Recv(clientInfo->_clientSocket, isClose);
        if (isClose)
        {
            LOG(INFO) << clientInfo->_clientIp << ":" << clientInfo->_clientPort << " close link......" << std::endl;
            break;  // 退出死循环
        }
        LOG(INFO) << clientInfo->_clientIp << ":" << clientInfo->_clientPort << "# " << message << std::endl;
        server->Send(clientInfo->_clientSocket, message);
    }
}

int main()
{
    TcpServer* server = new TcpServer();
    server->Start(func);
}